package sy.controller.${classname};

import sy.model.entity.${className};
import java.util.List;
import java.util.Map;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


import sy.service.${classname}.${className}Service;


@Controller
@RequestMapping(value = "/${classname}")
public class ${className}Controller {

	@Autowired
	private ${className}Service ${classname}Service;
	
	
	@RequestMapping(value = "/indexUI",method = { RequestMethod.GET, RequestMethod.POST })
	public String indexUI(${className} ${classname},HttpServletRequest request, HttpServletResponse response) {
	
		List ${classname}List=${classname}Service.getList(${classname});
		request.setAttribute("list${classname}", ${classname}List);
		return "/index/indexUI";
	}
	
	
	@RequestMapping(value = "/addUI",method = {RequestMethod.POST })
	public String addUI(${className} ${classname},HttpServletRequest request, HttpServletResponse response) {
		
		return "/index/addUI";
	}
	
	@RequestMapping(value = "/save",method = {RequestMethod.POST })
	public String save(${className} ${classname},HttpServletRequest request, HttpServletResponse response) {
	
		${classname}Service.save(${classname});		
		return "/index/addUI";
	}
	
	
	@RequestMapping(value = "/update",method = {RequestMethod.POST })
	public String update(${className} ${classname},HttpServletRequest request, HttpServletResponse response) {
	
		${classname}Service.update(${classname});	
		return "/index/addUI";	
	}
	
	@RequestMapping(value = "/viewUI",method = { RequestMethod.GET, RequestMethod.POST })
	public String viewUI(Integer id,HttpServletRequest request, HttpServletResponse response) {
	
		${className} ${classname}=${classname}Service.get(id);
		request.setAttribute("${classname}", ${classname});
		return "/index/viewUI";
	}
	

}